﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Web.UI;

public partial class UserControls_GoodType : UCBase 
{
    public UserControls_GoodType()
    {
        Name = "商品类型";

        swpas = new ShoveWebPartAttribute[15];
        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1000", 220, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("导航高度", "1,300", 28, "导航高度");
        swpas[2] = new ShoveWebPartAttribute_Int("导航背景图片单元格宽度", "1,600", 106, "导航背景图片单元格宽度");

        swpas[3] = new ShoveWebPartAttribute_Text("导航字体CSS样式", "", "title14_bai", "导航字体CSS样式");

        swpas[4] = new ShoveWebPartAttribute_Image("导航背景图片1", "", "images/title_bg_1.jpg", "导航背景图片1");
        swpas[5] = new ShoveWebPartAttribute_Image("导航背景图片2", "", "images/title_bg_hui.jpg", "导航背景图片2");
        swpas[6] = new ShoveWebPartAttribute_Image("More的图片", "", "images/more_1.jpg", "More的图片");

        swpas[7] = new ShoveWebPartAttribute_Int("控件高度", "1,1000", 280, "控件高度");
        swpas[8] = new ShoveWebPartAttribute_Int("大类别个数", "1,20", 5, "大类别个数");
        swpas[9] = new ShoveWebPartAttribute_Int("小类别个数", "1,30", 5, "小类别个数");
        swpas[10] = new ShoveWebPartAttribute_Int("大类别行高", "1,300", 35, "大类别行高");
        swpas[11] = new ShoveWebPartAttribute_Int("小类别行高", "1,300", 30, "小类别行高");
        swpas[12] = new ShoveWebPartAttribute_Text("大类别名样式", "", "td14", "大类别名样式");
        swpas[13] = new ShoveWebPartAttribute_Text("小类别名样式", "", "td12", "小类别名样式");

        swpas[14] = new ShoveWebPartAttribute_Color("控件边框颜色", "#E7C890", "控件边框颜色");
    }

    private void InitlayOut()
    {
        //tabctr.Width = swpAttributes[0];
        //tabctr.BgColor = swpAttributes[14];
        //tabctr.Height = swpAttributes[7];
        //trsign.Height = swpAttributes[1];

        //tdsign.Height = swpAttributes[1];
        //tdsign.Width = swpAttributes[2];
        //tdsign.Attributes.Add("class", swpAttributes[3]);
        //tdsign.Style.Add("background-image", "url('" + swpAttributes[4] + "')");
        //tdspace.Style.Add("background-image", "url('" + swpAttributes[5] + "')");
        //imgmore.Src = "~/" + swpAttributes[6];
        //tdspace.Width = (Shove._Convert.StrToInt(swpAttributes[0], 220) - Shove._Convert.StrToInt(swpAttributes[2], 106)).ToString();

        //trcenter.Height = (Shove._Convert.StrToInt(swpAttributes[7], 220) - Shove._Convert.StrToInt(swpAttributes[1], 28)).ToString();

        //sdlOneGoodType.ItemStyle.CssClass = swpAttributes[12];
        //sdlOneGoodType.ItemStyle.Height = new Unit(swpAttributes[10]);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        InitlayOut();
        LoadOneDatalist();
    }

    /// <summary>
    /// 绑定一级商品类型
    /// </summary>
    private void LoadOneDatalist()
    {
        int i = Shove._Convert.StrToInt(swpAttributes[8], 5);

        sdlOneGoodType.DataSource = new DAL.Tables.tbl_Shop_GoodType().Open("top " + i + " *", "ParentID = '0'", "");
        sdlOneGoodType.DataBind();
    }

    /// <summary>
    /// 绑定二级商品类型
    /// </summary>
    /// <param name="ID"></param>
    /// <returns></returns>
    public  DataTable   GetTwoGoodType(object ID)
    {
        int i = Shove._Convert.StrToInt(swpAttributes[9], 5);

        return new DAL.Tables.tbl_Shop_GoodType().Open("top "+ i +" *", "ParentID = '" + ID.ToString() + "'", "");
    }

    protected void sdlOneGoodType_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem || e.Item.ItemType == ListItemType.Item)
        {
            DataList dl = (DataList)e.Item.FindControl("dlTwoGoodType");
            dl.ItemStyle.Height =new Unit(swpAttributes[11]);
            dl.ItemStyle.CssClass = swpAttributes[13];
        }
    }
}
